package com.sam.im.heiqun.utils;

import android.text.TextUtils;

/**
 * Created by zhangqiang on 2018/7/6.
 */
public class MathUtil {

    public static int safeParseInt(String intString,int defaultValue){

        if(TextUtils.isEmpty(intString)){
            return defaultValue;
        }
        try {
            return Integer.valueOf(intString);
        }catch (Throwable t){
            t.printStackTrace();
        }
        return defaultValue;
    }

    public static double safeParseDouble(String doubleString,double defaultValue){

        if(TextUtils.isEmpty(doubleString)){
            return defaultValue;
        }
        try {
            return Double.valueOf(doubleString);
        }catch (Throwable t){
            t.printStackTrace();
        }
        return defaultValue;
    }

    public static long safeParseLong(String valueString,long defaultValue){

        if(TextUtils.isEmpty(valueString)){
            return defaultValue;
        }
        try {
            return Long.valueOf(valueString);
        }catch (Throwable t){
            t.printStackTrace();
        }
        return defaultValue;
    }
}
